class PullReviewComments
  attr_accessor :github

  def initialize(github)
    @github = github
  end

  def getComment(repo, id, user=nil)
    username = user == nil ? @github.username : user
    @github.get('repos/%s/%s/pulls/comments/%s' % [username, repo, id])
  end

  def listComments(repo, id, user=nil)
    username = user == nil ? @github.username : user
    @github.get('repos/%s/%s/pulls/%s/comments' % [username, repo, id])
  end

  def createComment(repo, id, body, commit_id, path, position, user=nil)
    username = user == nil ? @github.username : user
    params = {
        :body => body,
        :commit_id => commit_id,
        :path => path,
        :position => position
    }
    data = params.to_json
    @github.post('repos/%s/%s/pulls/%s/comments' % [username, repo, id], data)
  end

  def createCommentResponse(repo, id, body, in_reply_to, user=nil)
    username = user == nil ? @github.username : user
    params = {
        :body => body,
        :in_reply_to => in_reply_to
    }
    data = params.to_json
    @github.post('repos/%s/%s/pulls/%s/comments' % [username, repo, id], data)
  end

  def editComment(repo, id, body, user=nil)
    username = user == nil ? @github.username : user
    params = {
        :body => body
    }
    data = params.to_json
    @github.patch('repos/%s/%s/pulls/comments/%s' % [username, repo, id], data)
  end

  def deleteComment(repo, id, user=nil)
    username = user == nil ? @github.username : user
    @github.delete('repos/%s/%s/pulls/comments/%s' % [username, repo, id])
  end
end